home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / recv.man < prev    next >
Encoding:
Text File  |  1989-05-31  |  5.1 KB  |  133 lines

  1.  
  2.  
  3.  
  4. RECV                  C Library Procedures                   RECV
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      recv, recvfrom, recvmsg - receive a message from a socket
  10.  
  11. SSYYNNOOPPSSIISS
  12.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  13.      ##iinncclluuddee <<ssyyss//ssoocckkeett..hh>>
  14.  
  15.      cccc == rreeccvv((ss,, bbuuff,, lleenn,, ffllaaggss))
  16.      iinntt cccc,, ss;;
  17.      cchhaarr **bbuuff;;
  18.      iinntt lleenn,, ffllaaggss;;
  19.  
  20.      cccc == rreeccvvffrroomm((ss,, bbuuff,, lleenn,, ffllaaggss,, ffrroomm,, ffrroommlleenn))
  21.      iinntt cccc,, ss;;
  22.      cchhaarr **bbuuff;;
  23.      iinntt lleenn,, ffllaaggss;;
  24.      ssttrruucctt ssoocckkaaddddrr **ffrroomm;;
  25.      iinntt **ffrroommlleenn;;
  26.  
  27.      cccc == rreeccvvmmssgg((ss,, mmssgg,, ffllaaggss))
  28.      iinntt cccc,, ss;;
  29.      ssttrruucctt mmssgghhddrr **mmssgg;;
  30.      iinntt ffllaaggss;;
  31.  
  32. DDEESSCCRRIIPPTTIIOONN
  33.      _R_e_c_v, _r_e_c_v_f_r_o_m, and _r_e_c_v_m_s_g are used to receive messages
  34.      from a socket.
  35.  
  36.      The _r_e_c_v call is normally used only on a _c_o_n_n_e_c_t_e_d socket
  37.      (see _c_o_n_n_e_c_t(2)), while _r_e_c_v_f_r_o_m and _r_e_c_v_m_s_g may be used to
  38.      receive data on a socket whether it is in a connected state
  39.      or not.
  40.  
  41.      If _f_r_o_m is non-zero, the source address of the message is
  42.      filled in.  _F_r_o_m_l_e_n is a value-result parameter, initialized
  43.      to the size of the buffer associated with _f_r_o_m, and modified
  44.      on return to indicate the actual size of the address stored
  45.      there.  The length of the message is returned in _c_c.  If a
  46.      message is too long to fit in the supplied buffer, excess
  47.      bytes may be discarded depending on the type of socket the
  48.      message is received from (see _s_o_c_k_e_t(2)).
  49.  
  50.      If no messages are available at the socket, the receive call
  51.      waits for a message to arrive, unless the socket is non-
  52.      blocking (see _i_o_c_t_l(2)) in which case a _c_c of -1 is returned
  53.      with the external variable errno set to EWOULDBLOCK.
  54.  
  55.      The _s_e_l_e_c_t(2) call may be used to determine when more data
  56.      arrives.
  57.  
  58.      The _f_l_a_g_s argument to a recv call is formed by _o_r'ing one or
  59.      more of the values,
  60.  
  61.  
  62.  
  63. Sprite v1.0               July 21, 1987                         1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RECV                  C Library Procedures                   RECV
  71.  
  72.  
  73.  
  74.           #define  MSG_OOB         0x1    /* process out-of-band data */
  75.           #define  MSG_PEEK        0x2    /* peek at incoming message */
  76.  
  77.      The _r_e_c_v_m_s_g call uses a _m_s_g_h_d_r structure to minimize the
  78.      number of directly supplied parameters.  This structure has
  79.      the following form, as defined in <_s_y_s/_s_o_c_k_e_t._h>:
  80.  
  81.           struct msghdr {
  82.                caddr_t   msg_name;      /* optional address */
  83.                int  msg_namelen;        /* size of address */
  84.                struct    iovec *msg_iov;          /* scatter/gather array */
  85.                int  msg_iovlen;         /* # elements in msg_iov */
  86.                caddr_t   msg_accrights;      /* access rights sent/received */
  87.                int  msg_accrightslen;
  88.           };
  89.  
  90.      Here _m_s_g__n_a_m_e and _m_s_g__n_a_m_e_l_e_n specify the destination
  91.      address if the socket is unconnected; _m_s_g__n_a_m_e may be given
  92.      as a null pointer if no names are desired or required.  The
  93.      _m_s_g__i_o_v and _m_s_g__i_o_v_l_e_n describe the scatter gather loca-
  94.      tions, as described in _r_e_a_d(2).  A buffer to receive any
  95.      access rights sent along with the message is specified in
  96.      _m_s_g__a_c_c_r_i_g_h_t_s, which has length _m_s_g__a_c_c_r_i_g_h_t_s_l_e_n.  Access
  97.      rights are currently limited to file descriptors, which each
  98.      occupy the size of an iinntt.  If access rights are not being
  99.      transferred, the _m_s_g__a_c_c_r_i_g_h_t_s field should be set to NULL.
  100.  
  101. RREETTUURRNN VVAALLUUEE
  102.      These calls return the number of bytes received, or -1 if an
  103.      error occurred.
  104.  
  105. EERRRROORRSS
  106.      The calls fail if:
  107.  
  108.      [EBADF]             The argument _s is an invalid descriptor.
  109.  
  110.      [ENOTSOCK]          The argument _s is not a socket.
  111.  
  112.      [EWOULDBLOCK]       The socket is marked non-blocking and
  113.                          the receive operation would block.
  114.  
  115.      [EINTR]             The receive was interrupted by delivery
  116.                          of a signal before any data was avail-
  117.                          able for the receive.
  118.  
  119.      [EFAULT]            The data was specified to be received
  120.                          into a non-existent or protected part of
  121.                          the process address space.
  122.  
  123. SSEEEE AALLSSOO
  124.      fcntl(2), read(2), send(2), select(2), getsockopt(2),
  125.      socket(2)
  126.  
  127.  
  128.  
  129. Sprite v1.0               July 21, 1987                         2
  130.  
  131.  
  132.  
  133.